{% extends 'dashboard/base.html' %}

{% block body %}

            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-body">
                            <br>
                            <div class="d-md-flex align-items-center">
                                <h1 class="card-title">Add Vulnerability</h1>
                            </div>
                            <br>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="card">
                                        <form class="form-vertical" action="{% url 'pentest:add_vuln' %}"
                                              method="POST" enctype="multipart/form-data">
                                            {% csrf_token %}
                                            <div class="card-body">
                                                <input type="hidden" name="scan_id" value="{{ scan_id }}">
                                                <input type="hidden" name="project_id" value="{{ project_id }}">
                                                <div class="form-group row">
                                                    <label class="col-md-3 m-t-15"></label>
                                                    <div class="col-sm-8">
                                                        <select class="select2 form-control custom-select"
                                                                style="width: 50%; height:36px;"
                                                                onchange="location = this.value;">
                                                            <option>Vulnerability Search</option>
                                                            {% for data in all_vuln_data %}

                                                                <option value="{% url 'pentest:add_new_vuln' %}?scan_id={{ scan_id }}&vuln_id={{ data.vuln_data_id }}&project_id={{ project_id }}">
                                                                    {{ data.vuln_name }}
                                                                </option>

                                                            {% endfor %}
                                                        </select>
                                                        <div class="btn-group"><a
                                                                href="{% url 'pentest:add_vuln' %}?scan_id={{ scan_id }}&project_id={{ project_id }}"
                                                                class="btn btn-primary btn-sm"><i
                                                                class="icon-plus icon-white"></i>Add</a>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group row">{% for data in vuln_data %}
                                                    <label class="col-md-3 m-t-15">Vulnerability Name</label>
                                                    <div class="col-sm-8">
                                                        <input name="vuln_name" type="text" class="form-control"
                                                               value="{{ data.vuln_name }}"
                                                               placeholder="Last Name Here">
                                                    </div>
                                                    </div>

                                                    <div class="form-group row">
                                                        <label class="col-md-3 m-t-15">Severity</label>
                                                        <div class="col-sm-8">
                                                            <select name="vuln_severity"
                                                                    class="select2 form-control custom-select"
                                                                    style="width: 30%; height:36px;">
                                                                <option value="High">High</option>
                                                                <option value="Medium">Medium</option>
                                                                <option value="Low">Low</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-3 m-t-15">Pentest Type</label>
                                                        <div class="col-sm-8">
                                                            <select name="pentest_type"
                                                                    class="select2 form-control custom-select"
                                                                    style="width: 30%; height:36px;">
                                                                <option value="web">Web</option>
                                                                <option value="network">Network</option>
                                                                 <option value="static">Static</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label
                                                                class="col-md-3 m-t-15">Instance:</label>
                                                        <div class="col-sm-8">
                                                    <textarea name="vuln_instance" class="form-control"
                                                              style="margin-top: 0px; margin-bottom: 0px; height: 267px;"
                                                              placeholder="Instances"></textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label
                                                                class="col-md-3 m-t-15">Description:</label>
                                                        <div class="col-sm-8">
                                                    <textarea name="vuln_description" class="form-control"
                                                              style="margin-top: 0px; margin-bottom: 0px; height: 267px;"
                                                              placeholder="Company Name Here">{{ data.vuln_description }}</textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label
                                                                class="col-md-3 m-t-15">Solution</label>
                                                        <div class="col-sm-8">
                                                    <textarea name="vuln_solution" class="form-control"
                                                              style="margin-top: 0px; margin-bottom: 0px; height: 267px;"
                                                              placeholder="Contact No Here">{{ data.vuln_remediation }}</textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label
                                                                class="col-md-3 m-t-15">Reference</label>
                                                        <div class="col-sm-8">
                                                            <textarea name="vuln_reference" class="form-control"
                                                                      style="margin-top: 0px; margin-bottom: 0px; height: 267px;">{{ data.vuln_references }}</textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label
                                                                class="col-md-3 m-t-15">PoC Description</label>
                                                        <div class="col-sm-8">
                                                            <textarea name="poc_description" class="form-control"></textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-3">Upload PoC</label>
                                                        <div class="col-md-9">
                                                                <input type="file" name="poc">
                                                        </div>
                                                    </div>
                                                    </div>
                                                    <div class="float-right">
                                                        <div class="form-actions">
                                                            <button type="submit" class="btn btn-success">Save</button>
                                                        </div>
                                                    </div>
                                                    </form>
                                                {% endfor %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

    <script>
// Add the following code if you want the name of the file appear on select
$(".custom-file-input").on("change", function() {
  var fileName = $(this).val().split("\\").pop();
  $(this).siblings(".custom-file-label").addClass("selected").html(fileName);
});
</script>

{% endblock %}